import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 不常用。。。
 * @author gaopeng
 * @date 2019/12/21 6:17 下午
 */
public class Client {
    public static void main(String[] args) throws IOException {
        String expStr = getExpStr();
        Calculator calculator = new Calculator(expStr);
        int ret = calculator.run(getValue(expStr));
        System.out.println("表达式"+expStr+"的值为："+ret);
    }

    private static String getExpStr() throws IOException {
        System.out.println("请输入表达式。");
        return new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    private static Map<String,Integer> getValue(String expStr) {
        Map<String,Integer> map = new HashMap<>();
        for (char ch : expStr.toCharArray()) {
            if(ch!='+'&&ch!='-'){
                //解决重复参数问题
                if(!map.containsKey(String.valueOf(ch))){
                    System.out.println("请输入"+ch+"的值：");
                    int in = new Scanner(System.in).nextInt();
                    map.put(String.valueOf(ch),in);
                }
            }
        }
        return map;
    }
}
